const { get, post } = require("../../utils/request")
Page({
  data: {
    latitude: '37.404106',
    longitude: '112.438918',
    textData: {},
    markers:[],
    isAuto: false,
    isHidden: false,
    list:[],
    markerList: [],
    polyline: [],
    scale: 16,
    routeId: '',
    lat:'',
    lon:'',
    accuracy:'',
    horizontalAccuracy:''
  },
  onLoad: function(e) {
    this.mapCtx =  wx.createMapContext("map1",this)
    setTimeout(() => {
      this.mapCtx.addGroundOverlay({
        id: 1,
        src:'https://api.qiaoyard.cn/scenicarea/2024/08/12/mapmapmap_20240812011512A087.jpg',
        bounds:{
          southwest:{
            longitude:'112.435017',
            latitude:'37.403697'
          },
          northeast:{
            longitude:'112.442208',
            latitude:'37.408385'
          }
        },
        complete(res){
          console.log(res,'complete');
        }
      })
    }, 140);
  },
  //重新设置中心点
  setCenterFn(){
    var that = this
    wx.getLocation({
      type:'gcj02',
      isHighAccuracy: true,
      highAccuracyExpireTime: 100000,
      success (res) {
        that.mapCtx.moveToLocation({
          latitude:res.latitude,
          longitude: res.longitude
        })
      }
    })
    
  },
  getlocation(){
    var that = this
    wx.getLocation({
      type:'gcj02',
      isHighAccuracy: true,
      highAccuracyExpireTime: 100000,
      success (res) {
        const latitude = res.latitude
        const longitude = res.longitude
        const accuracy = res.accuracy
        const horizontalAccuracy = res.horizontalAccuracy
        that.setData({
          lat:latitude,
          lon:longitude,
          accuracy:accuracy,
          horizontalAccuracy:horizontalAccuracy
        })
      }
    })
  },
  onUnload(){
  },
})
